package com.zhang.servicemap.controller;

import com.zhang.internalcommon.dto.ResponseResult;
import com.zhang.internalcommon.response.TerminalResponse;
import com.zhang.internalcommon.response.TrsearchResponse;
import com.zhang.servicemap.service.TerminalService;
import jdk.nashorn.internal.ir.Terminal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 类功能描述
 *
 * @author Kye
 * @date 2025-04-15
 */
@RestController
@RequestMapping("/terminal")
public class TerminalController {
	@Autowired
	private TerminalService terminalService;

	/**
	 * 添加终端
	 * @param name
	 * @param desc
	 * @return
	 */
	@PostMapping("/add")
	public ResponseResult<TerminalResponse> addTerminal(@RequestParam String name, @RequestParam String desc) {
		return terminalService.addTerminal(name, desc);
	}

	/**
	 * 终端搜索
	 * @param center
	 * @param radius
	 * @return
	 */
	@PostMapping("/aroundSearch")
	public ResponseResult<List<TerminalResponse>> aroundSearch(String center, Integer radius) {
		return terminalService.aroundSearch(center, radius);
	}

	/**
	 * 轨迹查询
	 * @param tid
	 * @param starttime
	 * @param endtime
	 * @return
	 */
	@PostMapping("/trsearch")
	public ResponseResult<TrsearchResponse> trsearch(String tid, Long starttime, Long endtime) {
		return terminalService.trsearch(tid, starttime, endtime);
	}
}
